package com.itlong.cloud.operate.resource;

import com.itlong.cloud.POJO.DTO.operate.InterfaceDTO;
import com.itlong.cloud.POJO.PO.InterfacePO;
import com.itlong.cloud.POJO.VO.operate.InterfaceVO;
import com.itlong.cloud.operate.service.IOperateInterfaceService;
import com.itlong.cloud.project.operate.IOperateInterfaceServiceClient;
import com.itlong.cloud.utils.page.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <desc>
 *      :运营-接口类型-暴露接口实现类
 * <desc>
 * @date: 2021-08-16 14:05
 **/
@RestController
public class OperateInterfaceResource implements IOperateInterfaceServiceClient {

    @Autowired
    IOperateInterfaceService iOperateInterfaceService;

    /**
     * 保存接口
     * @param interfacePO 接口实体
     * @return
     * @throws Exception
     */
    @RequestMapping(path = "/saveInterface")
    public Integer saveInterface(@RequestBody InterfacePO interfacePO) throws Exception{
        return iOperateInterfaceService.save(interfacePO);
    }

    /**
     * <desc>
     *      :修改接口
     * <desc>
     * @param interfacePO
     * @return: java.lang.Integer
     * @date: 2021-08-16 14:08
     **/
    @RequestMapping(path = "/updateInterface")
    public Integer updateInterface(@RequestBody InterfacePO interfacePO) throws Exception{
        return iOperateInterfaceService.update(interfacePO);
    }

    /**
     * <desc>
     *      : 删除接口
     * <desc>
     * @param interfaceId 接口id
     * @param updateUserId 用户id
     * @return: java.lang.Integer
     * @date: 2021-08-16 14:09
     **/
    @RequestMapping(path = "/deleteInterface")
    public Integer deleteInterface(@RequestParam("interfaceId")String interfaceId,@RequestParam("updateUserId")String updateUserId) throws Exception{
        return iOperateInterfaceService.delete(interfaceId,updateUserId);
    }

    /**
     * <desc>
     *      : 条件查询列表
     * <desc>
     * @param interfaceName 接口名称
     * @param status 接口状态
     * @param startTime 开始时间
     * @param endTime 结束时间
     * @return: java.util.List<com.itlong.cloud.POJO.PO.InterfacePO>
     * @date: 2021-08-16 14:09
     **/
    @RequestMapping(path = "/getInterfaceList")
    public List<InterfacePO> getInterfaceList(@RequestParam("interfaceName")String interfaceName,
                                              @RequestParam("status")int status,
                                              @RequestParam("startTime")String startTime,
                                              @RequestParam("endTime")String endTime)throws Exception{
        return iOperateInterfaceService.getList(interfaceName,status,startTime,endTime);
    }

    /**
     * <desc>
     *      :分页查询接口列表
     * <desc>
     * @param interfaceDTO
     * @return: com.itlong.cloud.utils.page.Page<com.itlong.cloud.POJO.VO.operate.InterfaceVO>
     * @date: 2021-08-16 14:11
     **/
    @RequestMapping(path = "/getInterfacePageList")
    public Page<InterfaceVO> getInterfacePageList(@RequestBody InterfaceDTO interfaceDTO)throws Exception {
        return iOperateInterfaceService.getInterfacePageList(interfaceDTO);
    }

    /**
     * <desc>
     *      : 更新接口启用禁用状态
     * <desc>
     * @param interfaceId 接口id
     * @param status 接口状态
     * @param updateUserId 用户id
     * @return: java.lang.Integer
     * @date: 2021-08-16 14:11
     **/
    @RequestMapping(path = "/updateStatus")
    public Integer updateStatus(@RequestParam("interfaceId")String interfaceId,
                                @RequestParam("status") int status,
                                @RequestParam("updateUserId")String updateUserId) throws Exception{
        return iOperateInterfaceService.updateStatus(interfaceId,status,updateUserId);
    }

    /**
     * <desc>
     *      : 修改接口文档
     * <desc>
     * @param interfaceId 接口id
     * @param interfaceDocx 接口文档
     * @param updateUserId 用户id
     * @return: java.lang.Integer
     * @date: 2021-08-16 14:12
     **/
    @RequestMapping(path = "/updateDocx")
    public Integer updateDocx(@RequestParam("interfaceId")String interfaceId,
                              @RequestParam("interfaceDocx")String interfaceDocx,
                              @RequestParam("updateUserId")String updateUserId) throws Exception{
        return iOperateInterfaceService.updateDocx(interfaceId,interfaceDocx,updateUserId);
    }
}
